package com.sakila.pojo;

import java.io.Serializable;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import com.fasterxml.jackson.annotation.JsonIgnore;

public class Country implements Serializable {	
	/**
	 * 
	 */
	private static final long serialVersionUID = 2935814850864497487L;
	
	private Integer id;
	private String name;
	private Date lastUpdate;
	@JsonIgnore
	private Set<City> cities = new HashSet<City>();
	
	public Country() {
		// TODO Auto-generated constructor stub
	}

	public Country(String country, Date lastUpdate) {
		super();
		this.name = country;
		this.lastUpdate = lastUpdate;
	}

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public Date getLastUpdate() {
		return lastUpdate;
	}

	public void setLastUpdate(Date lastUpdate) {
		this.lastUpdate = lastUpdate;
	}

	public Set<City> getCities() {
		return cities;
	}

	public void setCities(Set<City> cities) {
		this.cities = cities;
	}
	
	public void addCity(City city){
		city.setCountry(this);
		cities.add(city);
	}
	
	public void removeCity(City city){
		city.setCountry(null);
		cities.remove(city);
	}
}
